var t = require("../../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../../@babel/runtime/regenerator")), e = require("../../../../@babel/runtime/helpers/asyncToGenerator"), a = getApp();

Component({
    properties: {
        auto_poster: {
            type: Number,
            value: 0
        },
        isset_poster: {
            type: Number,
            value: 0
        },
        activity_id: {
            type: Number,
            value: 0
        },
        staff_data: {
            type: Array,
            value: []
        },
        chat_data: {
            type: Object,
            value: {}
        },
        isRanking: {
            type: Boolean,
            value: !1
        }
    },
    data: {
        posterFlag: !1,
        staff_id: 0,
        posterSrc: "",
        serviceFlag: !1
    },
    lifetimes: {
        attached: function() {}
    },
    methods: {
        watchImg: function() {
            wx.previewImage({
                current: this.data.posterSrc,
                urls: [ this.data.posterSrc ]
            });
        },
        setStaffId: function(t) {
            this.setData({
                staff_id: t.currentTarget.dataset.id
            });
        },
        setPosterFlag: function() {
            this.data.posterSrc || 0 == this.data.auto_poster && 0 == this.data.isset_poster ? this.setData({
                posterFlag: !this.data.posterFlag
            }) : this.getPoster();
        },
        getPoster: function() {
            var r = this, i = {
                id: this.data.activity_id
            };
            if (0 == this.data.auto_poster && 0 == this.data.isset_poster) {
                if (0 == this.data.staff_id) return a.tips("请选择企业成员");
                i.staff_id = this.data.staff_id;
            }
            var s, n = a.getNetAddresss("plugin.customer-increase.frontend.activity.getPoster");
            a._postNetWork({
                url: n,
                data: i,
                success: (s = e(t.default.mark(function e(i) {
                    var s, n;
                    return t.default.wrap(function(t) {
                        for (;;) switch (t.prev = t.next) {
                          case 0:
                            if (1 == (s = i.data).result) {
                                t.next = 20;
                                break;
                            }
                            if (1 != s.data.need_agent) {
                                t.next = 10;
                                break;
                            }
                            return t.next = 5, a.confirm("您目前不是推广员，需要成为推广员才能生成海报。");

                          case 5:
                            return t.sent && wx.navigateTo({
                                url: "/packageA/member/extension/ExtensionApply/ExtensionApply"
                            }), t.abrupt("return");

                          case 10:
                            if (1 != s.data.need_member_level) {
                                t.next = 19;
                                break;
                            }
                            return n = s.data.member_level.join(","), t.next = 14, a.confirm("会员等级在【".concat(n, "】才可以参与活动，您当前的会员等级暂不能参与活动，快去升级吧~"));

                          case 14:
                            return t.sent && wx.navigateTo({
                                url: "/packageB/member/MemberGradeList/MemberGradeList"
                            }), t.abrupt("return");

                          case 19:
                            return t.abrupt("return", a.tips(s.msg));

                          case 20:
                            r.setData({
                                posterSrc: s.data.poster,
                                posterFlag: !0
                            });

                          case 21:
                          case "end":
                            return t.stop();
                        }
                    }, e);
                })), function(t) {
                    return s.apply(this, arguments);
                })
            });
        },
        gotoRanking: function() {
            this.data.isRanking || wx.navigateTo({
                url: "/packageF/wxFriendExtend/friendRanking/friendRanking?id=" + this.data.activity_id
            });
        },
        gotoChat: function(t) {
            var e = t.currentTarget.dataset.cservice;
            wx.navigateTo({
                url: e,
                fail: function(t) {
                    a.tips("客服路由出错");
                }
            });
        },
        gotoIndex: function() {
            wx.navigateTo({
                url: "/pages/index/index"
            });
        },
        openService: function() {
            this.setData({
                serviceFlag: !this.data.serviceFlag
            });
        },
        callPhone: function() {
            wx.makePhoneCall({
                phoneNumber: this.data.chat_data.mobile
            });
        }
    }
});